<?php
// Date in the past 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1 
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0 
header("Pragma: no-cache");
include_once('mq.php');
if (session_id() == '')
    session_start();
$login = substr($_POST['login'], 0, 14);
$password = substr($_POST['password'], 0, 16);
if(!empty($login) && !empty($password)) {
    $_SESSION['mq_l'] = $login;
    $_SESSION['mq_p'] = $password;
}
if (!empty($_SESSION['mq_l'])) {
    $login = substr((int) $_SESSION['mq_l'], 0, 14);
    $password = substr($_SESSION['mq_p'], 0, 16);
    
    $res = MQ_Query('USERINFO-login=' . $login . '|password=' . $password
        , T_CACHEDIR
        , T_CACHETIME
        , $login . '/');

    if ($res == '!!!CAN\'T CONNECT!!!') {
        $this->_CONNECTION_TIMEOUT = true;
        echo "<script>alert('Connect timeout.');history.go(-1);</script>";
        exit;
    }
}
if (empty($res) || strpos($res, 'Invalid') !== false || strpos($res, 'Disabled') !== false) {
    echo "<script>alert('Username/password error.');history.go(-1);</script>";
    exit;
}
?>
<?php
$info = explode("\r\n", $res);
$account = $info[0];
$name = $info[1];
?>
<!--<b>Account:</b> //= $account -->
<div class="con_text" style="margin-bottom:1px">
Welcome, <?= $name ?>
</div>
<?php
$beginIndex = 3;
$equity = MQ_GetParam($info[$beginIndex + 1]);
$margin = MQ_GetParam($info[$beginIndex + 2]);
?>
<table cellspacing="1" cellpadding="3" border="0" width="50%" style="margin-bottom: 30px;font-size:12px; font-family:Tahoma, Arial, Helvetica, sans-serif;">
    <tbody>
        <tr align="center" style="background-color: #a0a0a0;">
            <td><b>Equity</b></td>
            <td><b>Margin</b></td>
            <td><b>Free margin</b></td>
        </tr>
        <tr align="center" bgcolor="#cccccc">
            <td style="font-size:15px"><?= $equity ?></td>
            <td style="font-size:15px"><?= $margin ?></td>
            <td style="font-size:15px"><?= $equity - $margin ?></td>
        </tr>
    </tbody>
</table>





